<?php

/*
  |--------------------------------------------------------------------------
  | Application Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register all of the routes for an application.
  | It's a breeze. Simply tell Laravel the URIs it should respond to
  | and give it the Closure to execute when that URI is requested.
  |
 */
Route::group(array('before' => 'guest'), function() {
    //Trang chinh khi chua dang nhap
    Route::get('login', array('uses' => 'HomeController@index'));
    //Xu ly dang nhap
    Route::post('login', array('before' => 'csrf', 'uses' => 'HomeController@postLogin'));
});

Route::group(array('before' => 'auth'), function() {
    //Trang chinh khi da dang nhap
    Route::get('/', array('uses' => 'QuanLyController@index'));
    //Quan ly danh sach thong tin
    Route::get('ql={type}', array('uses' => 'QuanLyController@index'))->where(array('type' => '[A-Za-z0-9]+'));
    //Them bieu mau
    Route::get('add={type}', array('uses' => 'QuanLyController@add'))->where(array('type' => '[A-Za-z0-9]+'));
    //Xem chi tiet thong tin
    Route::get('view={type}', array('uses' => 'QuanLyController@show'))->where(array('type' => '[A-Za-z0-9]+'));
    //Tim kiem thong tin
    Route::get('search={type}', array('uses' => 'QuanLyController@search'))->where(array('type' => '[A-Za-z0-9]+'));
    //Xoa thong tin
    Route::get('delete={type}', array('uses' => 'QuanLyController@remove'))->where(array('type' => '[A-Za-z0-9]+'));
    //Luu thong tin moi
    Route::post('save={type}', array('before' => 'csrf','uses' => 'QuanLyController@save'))->where(array('type' => '[A-Za-z0-9]+'));
    //Luu thong tin sua
    Route::post('store={type}', array('before' => 'csrf','uses' => 'QuanLyController@store'))->where(array('type' => '[A-Za-z0-9]+'));
    //Xu ly ajax
    Route::get('ajax={type}', array('uses' => 'QuanLyController@ajax'))->where(array('type' => '[A-Za-z0-9]+'));
    //Xu ly dang xuat
    Route::get('logout', array('uses' => 'HomeController@getLogout'));
    //Luu noi dung kiem tra
    Route::post('savenoidung', array('uses' => 'ChiTietCuocKiemTraController@saveNoiDung'));
    //Luu nghia vu kiem tra
    Route::post('savenghiavu', array('uses' => 'ChiTietCuocKiemTraController@saveNghiaVu'));
    //Luu phan tich chuyen sau nguoi nop thue
    Route::post('savephantichchuyensau', array('uses' => 'CuocKiemTraController@savePhanTichChuyenSau'));
    //Xóa tất cả nội dung
    Route::get('xoand', array('uses' => 'ChiTietCuocKiemTraController@xoaNoiDung'));
    //Xóa tất cả nghĩa vụ
    Route::get('xoanv', array('uses' => 'ChiTietCuocKiemTraController@xoaNghiaVu'));
});
